function receptionReimburse($scope, $route, CertusFormAjax, CertusJsonAjax, $location, $http, $cookies, $routeParams, $q, backlogPersonList) {

    $backlogPersonList = backlogPersonList;
    $$scope = $scope;
    //初始化 相关 数据
    $scope.dataList = {}
    $scope.receptionTribursementEntity = {};

    var nowProjName;

    function isSaveProjName(element) {
        return element.projName.indexOf(nowProjName) > -1;
    }

    $scope.companyCodeChange = function (a) {
        for (var cs in $scope.dataList.companySelect) {

            if ($scope.dataList.companySelect[cs].code == a) {
                $scope.receptionTribursementEntity.typeName = $scope.dataList.companySelect[cs].name;
            }
        }
    }
    //监听项目名称
    $scope.$watch("receptionTribursementEntity.projName", function (newValue, old, scope) {

        if (old && newValue) {
            if (newValue.indexOf(old) > -1) {
                nowProjName = newValue;
                scope.dataList.projNameSelect = scope.dataList.projNameSelect.filter(isSaveProjName);
                if (scope.dataList.projNameSelect.length) {
                    if (scope.dataList.projNameSelect.length == 1) {
                        scope.receptionTribursementEntity.projId = scope.dataList.projNameSelect[0].projId;
                        scope.receptionTribursementEntity.projName = scope.dataList.projNameSelect[0].projName;
                    }
                }
                if(!scope.dataList.projNameSelect || scope.dataList.projNameSelect.length == 0){
                    scope.receptionTribursementEntity.projId = "";
                    scope.receptionTribursementEntity.projName = "";
                }
                return;
            }
        }

        //直接去数据库 查询
        CertusFormAjax.ajax("relatedProj", {param: newValue}, function (res) {
            scope.dataList.projNameSelect = res.data;
            if (scope.dataList.projNameSelect.length) {
                if (scope.dataList.projNameSelect.length == 1) {
                    scope.receptionTribursementEntity.projId = scope.dataList.projNameSelect[0].projId;
                    scope.receptionTribursementEntity.projName = scope.dataList.projNameSelect[0].projName;
                }
            }
        })
    })

    //公司 选择
    $scope.dataList.companySelect = [
        {name: "外部招待", code: "WBZD"},
        {name: "内部团建", code: "NBTJ"},
    ]

    var cusProjName;

    function isSaveCusName(element) {
        return element.comName.indexOf(cusProjName) > -1;
    }


    var nowTriburse;

    function isSaveRetribursementName(element) {
        return element.borrowerCode.indexOf(nowTriburse) > -1;
    }

    //客户 公司 code
    $scope.$watch("receptionTribursementEntity.borrowCode", function (newValue, old, scope) {
        if (old && newValue) {
            if (newValue.indexOf(old) > -1) {
                nowTriburse = newValue;
                scope.dataList.triburseSelect = scope.dataList.triburseSelect.filter(isSaveRetribursementName);
                if (scope.dataList.triburseSelect.length) {
                    if (scope.dataList.triburseSelect.length == 1) {
                        // scope.receptionTribursementEntity.borrowCode = scope.dataList.cusCompSelect[0].id;
                        scope.receptionTribursementEntity.borrowCode = scope.dataList.triburseSelect[0].borrowerCode;
                    }
                }
                return;
            }
        }
        //直接去数据库 查询
        CertusFormAjax.ajax("borrowingEntityList", {borrowCode: newValue}, function (res) {
            scope.dataList.triburseSelect = res.data;
            if (scope.dataList.triburseSelect.length) {
                if (scope.dataList.triburseSelect.length == 1) {
                    // scope.receptionTribursementEntity.customUnitId = scope.dataList.cusCompSelect[0].id;
                    scope.receptionTribursementEntity.borrowCode = scope.dataList.triburseSelect[0].borrowerCode;
                }
            }
        })
    })

    //提交流程
    $scope.zdbxlcSubmit = function () {
        if (certusValidateNotnull()) {
            /*if (!$scope.receptionTribursementEntity.customUnitId) {
                layer.msg("客户单位未填写");
                return;
            }*/

            if (!$scope.receptionTribursementEntity.projId) {
                layer.msg("项目未填写");
                return;
            }

            if ($scope.receptionTribursementEntity.chargeAgainest || $scope.receptionTribursementEntity.borrowCode) {
                if ($scope.receptionTribursementEntity.chargeAgainest && $scope.receptionTribursementEntity.borrowCode) {
                } else {
                    layer.msg("请补全冲销信息");
                    return;
                }
            }
            $scope.receptionTribursementStepEntity = {};
            CertusJsonAjax.ajax("zdbxlcSubmit", $scope.receptionTribursementEntity, function (res) {
                if (res.data == "success") {
                    findBacklogPersonHead(CertusFormAjax, "ZDBXLC");
                    window.history.back();
                    return;
                }
                layer.msg(res.data)
            })
        }
    }
    //校验 俩个 id


}

function receptionInfoDetailmeth1($scope, $route, CertusFormAjax, CertusJsonAjax, $location, $http, $cookies, $routeParams) {
    if ($routeParams && $routeParams.trCode) {
        CertusFormAjax.ajax("queryReceptionByCode", {rtCode: $routeParams.trCode}, function (res) {

            $scope.receptionTribursementEntity = res.data;
            $scope.processs = res.data.processs;
        })
    }

    $scope.getsssbbb = function (bb) {
        if (bb == "starting") {
            return "正在进行中";
        } else if (bb == "denied") {
            return "否决";
        } else if (bb == "sentback") {
            return "被退";
        } else if (bb == "others") {
            return "关闭";
        } else if(bb == "completed"){
            return "完成";    }else if(bb == "terminated"){        return "终结";    }    else if(bb == "cancelled"){        return "通过";}
        return "待办";
    }
}